/*******************************************************************************
 * Copyright (c) 2005, 2007 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package us.gaaoc.framework.dao;

import java.util.Date;

import org.apache.log4j.Logger;

import org.hibernate.Query;
import us.gaaoc.framework.model.Counter;

/**
 * Home object for domain model class Counter.
 * 
 * @see us.gaaoc.framework.model.Counter
 * @author Hibernate Tools
 */
public class CounterDAOHibernate extends GenericHibernateDAO<Counter, String, CounterDAO>
implements  CounterDAO{
	
	private static final Logger LOG = Logger.getLogger(CounterDAOHibernate.class);

	protected CounterDAOHibernate() {}
	
	public Counter getCounter(){
		LOG.info("A query for the counter rows is going to be created .....");
		Query q = this.getSession().createQuery("from Counter");
		//q.setString("onlyOneRecord", "counterUuid");
		LOG.info("A query for the counter rows has been created .....");
		return (Counter) q.uniqueResult();
	}

	public void updateCounter(String counterUuid, int counterValue) {
		 Counter counter = this.getCounter();
		 counter.setCounterUuid(counterUuid);
		 counter.setCounterValue(counterValue);
		 this.makePersistent(counter);
		
		
	}

	
	
} 
